package main

import "fmt"

/**
方法+他绑定的上下文
*/
// 闭包
func Closure(name string) func() string {
	return func() string {
		return "hello " + name
	}
}

func Closure1() func() string {
	name := "nexora"
	age := 18
	return func() string {
		return fmt.Sprintf("Hello, %s, %d", name, age)
	}
}

func Closure2() func() int {
	var age = 0
	//fmt.Printf("%p",&age)
	return func() int {
		age++
		//fmt.Printf("%p",&age)
		return age
	}
}
